/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Golf_Manager.vo;


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author Administrator
 */
public class Member {
    private String memberSeq;
    private String name;
    private String birth;
    private String age;
    private String gender;
    private String companyName;
    private String hand;
    private String grade;
    private String joinYn;
    private String note1;
    private String note2;
    private String note3;
    private String flag;
    
    public Member() {
    }
    
    public Member(String flag) {
        this.memberSeq = "";
        this.flag = flag;
    }
    
    public Member(String name, String birth) {
        this.name = name;
        this.birth = birth;
    }

    public Member(String memberSeq, String name, String birth, String age, String gender, String companyName, String hand, String grade, String joinYn, String note1, String note2, String note3, String flag) {
        this.memberSeq = memberSeq;
        this.name = name;
        this.birth = birth;
        this.age = age;
        this.gender = gender;
        this.companyName = companyName;
        this.hand = hand;
        this.grade = grade;
        this.joinYn = joinYn;
        this.note1 = note1;
        this.note2 = note2;
        this.note3 = note3;
        this.flag = flag;
    }
    
    public String getMemberSeq() {
        return memberSeq;
    }

    public void setMemberSeq(String memberSeq) {
        this.memberSeq = memberSeq;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBirth() {
        return birth;
    }

    public void setBirth(String birth) {
        this.birth = birth;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }
    
    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getHand() {
        return hand;
    }

    public void setHand(String hand) {
        this.hand = hand;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getJoinYn() {
        return joinYn;
    }

    public void setJoinYn(String joinYn) {
        this.joinYn = joinYn;
    }

    public String getNote1() {
        return note1;
    }

    public void setNote1(String note1) {
        this.note1 = note1;
    }

    public String getNote2() {
        return note2;
    }

    public void setNote2(String note2) {
        this.note2 = note2;
    }

    public String getNote3() {
        return note3;
    }

    public void setNote3(String note3) {
        this.note3 = note3;
    }

    public String getFlag() {
        return flag;
    }
    
    public void setFlag(String flag) {
        this.flag = flag;
    }
    
    @Override
	public String toString() {
		Class cls = this.getClass();
		Method[] arrMethod = cls.getMethods();
		StringBuilder sb = new StringBuilder(this.getClass().toString());
		sb.append(" => ");
		
		try {
			for(Method m : arrMethod) {
				if(m.getName().startsWith("get") && !m.getName().equals("getClass")) { 
					sb.append(m.getName());
					sb.append(": ");
					sb.append(m.invoke(this));
					sb.append(", ");
				}
			}
		} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
			Logger.getLogger(Member.class.getName()).log(Level.SEVERE, null, e);
		}
		
		return sb.toString().substring(0, sb.length() - 2);
	}
        
        public ValidVo vlidCheck() {
            if(this.getName() == null || this.getName().equals("")){
                return new ValidVo("이름은 필수 입력 입니다.", 0);
            }
            if(this.getBirth() == null || this.getBirth().trim().length() != 10){
                return new ValidVo("생년 월일은 필수 입력 입니다.", 1);
            }
            if(this.getGrade() == null || this.getGrade().equals("")){
                return new ValidVo("등급은 필수 입력 입니다.", 6);
            }
            if(this.getJoinYn() == null || this.getJoinYn().equals("")){
                return new ValidVo("참여여부는 필수 입력 입니다.", 7);
            }
            return null;
	}    
    
}
